<div class="Item hr clearfix">
    <span class="fr">现有投票选项 <b>{$rows_count}</b> </span>
    <div class="current">投票选项列表</div>
</div>

<form>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
        <thead>
            <tr>
                <td>ID</td>
                <td>排序</td>
                <td>名称</td>
                <td>投票数</td>
                <td>颜色值</td>
                <td>更新时间</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
            <volist name="votes" id="vote">
                <tr align="center">
                    <td>{$vote['id']}</td>
                    <td><input type="hidden" name="sortids[]" value="{$vote['id']}" /><input type="text" name="sorts[]" value="{$vote['sort']}" style="width:50px; text-align:center;" /></td>
                    <td>{$vote['name']}</td>
                    <td>{$vote['count']}</td>
                    <td style="color: {$vote['color']}; font-weight: bold;">{$vote['color']}</td>
                    <td>{:date('Y-m-d H:i', $vote['updated_at'])}</td>
                    <td>[ <a href="{:U('Vote/edit', array('id' => $vote['id']))}">编辑</a> ] [ <a href="javascript:void(0);" value="{:U('Vote/delete', array('id' => $vote['id']))}" name="({$vote['title']})" class="del">删除</a> ]</td>
                </tr>
            </volist>
        </tbody>
    </table>
</form>

<div class="page">
    {$page}
</div>

<div class="commonBtnArea" >
    <button class="btn sort">排序</button>
</div>

<script type="text/javascript">
    $(function() {
        $(".del").click(function() {
            var del_link = $(this).attr("value");
            popup.confirm('你真的打算删除 <b>' + $(this).attr("name") + '</b> 投票选项吗?', '温馨提示', function(action) {
                if (action == 'ok') {
                    $.getJSON(del_link, function(json) {
                        if (json.status) {
                            popup.success(json.info);
                            setTimeout(function() {
                                popup.close("asyncbox_success");
                            }, 2000);
                        } else {
                            popup.error(json.info);
                            setTimeout(function() {
                                popup.close("asyncbox_error");
                            }, 2000);
                        }

                        setTimeout(function() {
                            top.window.location.reload();
                        }, 1000);
                    });
                }
            });

            return false;
        });
    });
    
    //排序
    $(".sort").click(function(){
        commonAjaxSubmit("{:U('Vote/sort')}");
    });
</script>